package cn.com.zpark.jdbc;

import cn.com.zpark.jdbc.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @PackageName: cn.com.zaprk.jdbc
 * @ClassName: JDBC_07_Delete
 * @Description:
 * @author: RZS
 * @date: 2021/10/20  18:05
 */
public class JDBC_04_Delete {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stat = null;
        try {
            // 2、获取连接
            conn = JDBCUtils.getConn();
            // 3、创建Statement对象，用于执行sql
            stat = conn.createStatement();
            // 4、编写sql
            String sql = "delete from user where id=3";
            // 5、执行sql
            int row = stat.executeUpdate(sql);
            System.out.println(row);
            // 6、获取sql执行结果
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            // 7、关闭连接
            JDBCUtils.close(null, stat, conn);
        }
    }
}
